package com.wnhz.work.yz.adapter;

import android.content.Context;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.util.Log;
import android.view.View;

import com.wnhz.work.yz.R;
import com.wnhz.work.yz.activity.AddAccurateActivity;
import com.wnhz.work.yz.activity.LookDetailsActivity;
import com.wnhz.work.yz.base.BaseRVAdapter;
import com.wnhz.work.yz.base.BaseViewHolder;
import com.wnhz.work.yz.bean.RecordsItemBean;

import java.util.List;

public class RecordAdapter extends BaseRVAdapter {

    private List<RecordsItemBean.InfoEntity> info;
    private int type;

    public void setType(int type) {
        this.type = type;
    }

    /**
     * 构造器
     *
     * @param context 上下文
     * @param list    数据集合
     */
    public RecordAdapter(Context context, @NonNull List list) {
        super(context, list);
        info = list;
    }

    @Override
    public int getLayoutId(int viewType) {
        return R.layout.item_records;
    }

    @Override
    public void onBind(BaseViewHolder holder, final int position) {
        holder.setTextView(R.id.name, info.get(position).getName());
        holder.setTextView(R.id.product_type, info.get(position).getType());
        holder.setTextView(R.id.nums, info.get(position).getNums());
        holder.setTextView(R.id.max_money, info.get(position).getBudget());
        holder.setTextView(R.id.time, info.get(position).getCreate_at());
        holder.setTextView(R.id.address, info.get(position).getAddress());
        holder.getView(R.id.rl_max).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if ("0".equals(info.get(position).getType_id())) {
                    //线索
                    intent = new Intent(mContext, AddAccurateActivity.class);
                    intent.putExtra("isUpdate", 1);
                    Log.e("=================","cnmcnmcncmncncncnncn");
                } else if ("1".equals(info.get(position).getType_id())) {
                    //精确
                    intent = new Intent(mContext, LookDetailsActivity.class);
                }
                intent.putExtra("recordid", info.get(position).getRecordid());
                mContext.startActivity(intent);
            }
        });
    }

    private Intent intent;
}